package main.java.chm;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @Date 2023/7/30 21:53
 * @Author 李荣浩
 * @Description
 */
public class ConcurrentHashMapExample {

    public static void main(String[] args) {
        ConcurrentHashMap<String, Integer> concurrentHashMap = new ConcurrentHashMap<>();
        concurrentHashMap.put("test", 1);
        concurrentHashMap.get("test");
        concurrentHashMap.computeIfAbsent("test1", k -> 1);
        concurrentHashMap.computeIfPresent("test1", (k, v) -> v + 1);
        concurrentHashMap.merge("test", 5, Integer::sum);
        System.out.println(concurrentHashMap);
    }
}
